/**
 * 
 */
package cn.iune.erp.purchase;

import java.math.BigDecimal;
import java.sql.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

import com.justep.baas.data.RowState;

/**
 * @author Administrator
 *
 */
@Entity
@Table(name = "PurchaseOrderDetail"
, uniqueConstraints = { 
	@UniqueConstraint(columnNames = { "stockNo", "serialNo", "enterpriseNo" }) 
}
)@NamedQuery(name="PurchaseOrderDetail.findAll", query="SELECT s FROM PurchaseOrderDetail s")
public class PurchaseOrderDetail {

	@Id
	@Column(length=36)
	private String fID;
	
	@Column(length=32)
	private String systemCode;
	@Column(length=4)
	private String billType;
	@Column(length=20)
	private String billTypeName;
	private Date orderDate;
	@Column(length=10)
	private String state = "active";
	@Column(length=10)
	private String status = "open";
	@Column(length=10)
	private String audit = "active";

//	@Column(length=1)
//	private String revOpay;
//	private int direction = 0;
//	@Column(length=1)
//	private String costingCode;
	private Date confirmDate;
	
	@Column(length=4)
	private String origin;
	@Column(length=20)
	private String originName;
	@Column(length=20)
	private String originNo;
	@Column(length=5)
	private String originSerialNo;
	
	@Column(length=15)
	private String stockNo;
	
	@Column(length=32)
	private String factoryID;
	@Column(length=15)
	private String factoryNo;
	@Column(length=20)
	private String factoryName;
	
	@Column(length=3)
	private String storageTypeD;
	@Column(length=20)
	private String storageTypeDLabel;
	@Column(length=32)
	private String providerID;
	@Column(length=15)
	private String providerNo;
	@Column(length=20)
	private String shortName;
	@Column(length=128)
	private String providerName;
	
	@Column(length=3)
	private String storageType;
	@Column(length=20)
	private String storageTypeLabel;
	@Column(length=32)
	private String storageID;
	@Column(length=15)
	String storageNo;
	@Column(length=20)
	String storageName;
	@Column(length=128)
	private String floorNo;
	@Column(length=5)
	private String allowed;//库存量不足准许出库：yes，否则：no
	
//	private String factoryNoOut;
//	private String factoryNameOut;
	
	private int taxType = 0;
	@Column(length=10)
	private String taxTypeLabel;
	@Column(precision=10,scale=2)
	private BigDecimal taxRate = BigDecimal.ZERO;

	@Column(length=5)
	private String serialNo;
	@Column(length=32)
	private String fMasterID;
	
	private int checkin = 1;//是否参加出入库登记（影响单据总数量）。不参加（不计入单据总数量）：0，参加：1
	
	@Column(length=32)
	private String itemID;
	@Column(length=30)
	private String itemNo;
	@Column(length=100)
	private String itemName;
	@Column(length=512)
	private String itemProperty;// = "*****";
	@Transient
	private String itemDescribe;
	@Column(length=15)
	private String unitCode;
	@Column(length=20)
	private String unitName;

	/////////////////////////////////////////////////////////////////
	@Transient
	private int qualityType = 0;
	@Transient
	@Column(length=10)
	private String qualityTypeLabel = "0:免检";//0:免检,1:抽检,2:全检
	@Transient
	@Column(length=20)
	private String batchNo;
	@Transient
	private int qualityPeriod = 0;//0,不启用保质期管理；1，启用
	@Transient
	private int validDays = 0;//有效天数
	@Transient
	private int checkoutAgainDays = 0;//复检天数
	
	@Transient
	@Column(length=1024)
	private String storeNo;
	@Transient
	@Column(length=1024,columnDefinition="TEXT")
	private String images;
	@Transient
	@Column(length=256)
	private String imageurl;

	@Transient
	@Column(length=1)
	private String process;
	@Transient
	@Column(length=10)
	private String processLabel;
	///////////////////////////////////////////////////////////////////////////
	
	@Column(precision=38,scale=6)
	private BigDecimal itemPrice = BigDecimal.ZERO;
	//下面这一列是为了使用通用金额计算公式，没有实际作用
//	@Column(precision=10,scale=2)
//	private BigDecimal discountRate = BigDecimal.ZERO;

	@Column(precision=10,scale=2)
	private BigDecimal itemAmount = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmount = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmountOld = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmountTax = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmountTotal = BigDecimal.ZERO;

	//件装（每包装数量，如：每箱啤酒24瓶piecePackage=24，itemAmount=48，则pieceQuantity=2件）
	@Column(precision=10,scale=2,columnDefinition="DECIMAL(10,2) default 0")
	private BigDecimal piecePackage = BigDecimal.ZERO;
	//件数
	@Column(precision=10,scale=2)
	private BigDecimal pieceQuantity = BigDecimal.ZERO;
	
	private Date requirementDate;

	@Column(precision=10,scale=2)
	private BigDecimal storeItemIng = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
	private BigDecimal storeItemAmount = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
	private BigDecimal storePiece = BigDecimal.ZERO;  

//	@Column(precision=10,scale=2)
//	private BigDecimal backItemIng = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
	private BigDecimal backItemAmount = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
	private BigDecimal backPiece = BigDecimal.ZERO;  
	
	//可出库数量=itemAmount-pickItemIng-pickItemAmount(与累计退库数量backItemAmount无关)
	@Transient
	@Column(precision=10,scale=2)
	private BigDecimal pendingQuantity = BigDecimal.ZERO;//可出库数量
	@Transient
	@Column(precision=10,scale=2)
	private BigDecimal pendingPiece = BigDecimal.ZERO;//可出库件数

//	@Column(length=20)
//	private String batchNo;
//	private int qualityPeriod = 0;//保质期管理0;1
//
//	@Column(length=10)
//	private String brand;
//	@Column(length=20)
//	private String brandLabel;
//	@Column(length=20)
//	private String placeOrigin;
//	@Column(length=128)
//	private String manufacturer;
//	
//	@Column(length=1024)
//	private String storeNo;

	@Column(precision=10,scale=2)
	private BigDecimal itemWeight = BigDecimal.ZERO;
	@Column(length=20)
	private String itemSize;

	@Column(precision=10,scale=2)
	private BigDecimal orderWeight = BigDecimal.ZERO;
	@Column(length=20)
	private String orderSize;
	
	@Column(length=20)
	private String projectNo;
	@Column(length=15)
	private String orderNo;

	//作废
//	@Column(precision=38,scale=2)
//	private BigDecimal freightAmount = BigDecimal.ZERO;//运费
	//作废
//	@Column(precision=38,scale=2)
//	private BigDecimal apportionAmount = BigDecimal.ZERO; //其他费用
	
	@Column(length=20)
	private String resultStatus = "待审核";

//	@Column(length=32)
//	private String departmentNo;
//	@Column(length=128)
//	private String departmentName;
	@Column(length=256)
	private String employeeNo;
	@Column(length=256)
	private String employeeName;

	@Column(length=255)
	private String comments;
	
	@Column(length=128)
	private String userId;

	@Column(length=128)
	private String enterpriseNo;
	@Column(length=128)
	private String enterpriseName;

	@Version
	private int version = 0;
	
	@Transient//非持久字段
	private RowState rowState;
	public RowState getRowState() {
		return rowState;
	}
	public void setRowState(RowState rowState) {
		this.rowState = rowState;
	}


	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Date getRequirementDate() {
		return requirementDate;
	}

	public void setRequirementDate(Date requirementDate) {
		this.requirementDate = requirementDate;
	}

	public BigDecimal getPendingQuantity() {
		return pendingQuantity;
	}
	public void setPendingQuantity(BigDecimal pendingQuantity) {
		this.pendingQuantity = pendingQuantity;
	}
	public BigDecimal getPendingPiece() {
		return pendingPiece;
	}
	public void setPendingPiece(BigDecimal pendingPiece) {
		this.pendingPiece = pendingPiece;
	}
	public BigDecimal getBackItemAmount() {
		return backItemAmount;
	}

	public void setBackItemAmount(BigDecimal backItemAmount) {
		this.backItemAmount = backItemAmount;
	}

	public BigDecimal getBackPiece() {
		return backPiece;
	}

	public void setBackPiece(BigDecimal backPiece) {
		this.backPiece = backPiece;
	}
	public BigDecimal getItemWeight() {
		return itemWeight;
	}
	public void setItemWeight(BigDecimal itemWeight) {
		this.itemWeight = itemWeight;
	}
	public String getItemSize() {
		return itemSize;
	}
	public void setItemSize(String itemSize) {
		this.itemSize = itemSize;
	}
	public BigDecimal getOrderWeight() {
		return orderWeight;
	}
	public void setOrderWeight(BigDecimal orderWeight) {
		this.orderWeight = orderWeight;
	}
	public String getOrderSize() {
		return orderSize;
	}
	public void setOrderSize(String orderSize) {
		this.orderSize = orderSize;
	}
	public String getProjectNo() {
		return projectNo;
	}
	public void setProjectNo(String projectNo) {
		this.projectNo = projectNo;
	}
	public String getOrderNo() {
		return orderNo;
	}
	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}
	public int getTaxType() {
		return taxType;
	}
	public void setTaxType(int taxType) {
		this.taxType = taxType;
	}
	public String getTaxTypeLabel() {
		return taxTypeLabel;
	}
	public void setTaxTypeLabel(String taxTypeLabel) {
		this.taxTypeLabel = taxTypeLabel;
	}
	public BigDecimal getTaxRate() {
		return taxRate;
	}
	public void setTaxRate(BigDecimal taxRate) {
		this.taxRate = taxRate;
	}
	public BigDecimal getItemPrice() {
		return itemPrice;
	}
	public void setItemPrice(BigDecimal itemPrice) {
		this.itemPrice = itemPrice;
	}
	public String getStorageType() {
		return storageType;
	}
	public void setStorageType(String storageType) {
		this.storageType = storageType;
	}
	public String getStorageTypeLabel() {
		return storageTypeLabel;
	}
	public void setStorageTypeLabel(String storageTypeLabel) {
		this.storageTypeLabel = storageTypeLabel;
	}
	public String getFloorNo() {
		return floorNo;
	}
	public void setFloorNo(String floorNo) {
		this.floorNo = floorNo;
	}
	public String getProviderNo() {
		return providerNo;
	}
	public void setProviderNo(String providerNo) {
		this.providerNo = providerNo;
	}
	public String getShortName() {
		return shortName;
	}
	public void setShortName(String shortName) {
		this.shortName = shortName;
	}
	public String getProviderName() {
		return providerName;
	}
	public void setProviderName(String providerName) {
		this.providerName = providerName;
	}
	public String getOriginName() {
		return originName;
	}
	public void setOriginName(String originName) {
		this.originName = originName;
	}
	public Date getOrderDate() {
		return orderDate;
	}
	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getAudit() {
		return audit;
	}
	public void setAudit(String audit) {
		this.audit = audit;
	}
	public String getBillTypeName() {
		return billTypeName;
	}
	public void setBillTypeName(String billTypeName) {
		this.billTypeName = billTypeName;
	}
	public String getStockNo() {
		return stockNo;
	}
	public void setStockNo(String stockNo) {
		this.stockNo = stockNo;
	}
	public String getFactoryNo() {
		return factoryNo;
	}
	public void setFactoryNo(String factoryNo) {
		this.factoryNo = factoryNo;
	}
	public String getFactoryName() {
		return factoryName;
	}
	public void setFactoryName(String factoryName) {
		this.factoryName = factoryName;
	}
	public BigDecimal getPieceQuantity() {
		return pieceQuantity;
	}
	public void setPieceQuantity(BigDecimal pieceQuantity) {
		this.pieceQuantity = pieceQuantity;
	}
	public String getOrigin() {
		return origin;
	}
	public void setOrigin(String origin) {
		this.origin = origin;
	}
	public String getOriginNo() {
		return originNo;
	}
	public void setOriginNo(String originNo) {
		this.originNo = originNo;
	}
	public Date getConfirmDate() {
		return confirmDate;
	}
	public void setConfirmDate(Date confirmDate) {
		this.confirmDate = confirmDate;
	}
	public BigDecimal getStorePiece() {
		return storePiece;
	}
	public void setStorePiece(BigDecimal storePiece) {
		this.storePiece = storePiece;
	}
	public String getfID() {
		return fID;
	}

	public void setfID(String fID) {
		this.fID = fID;
	}
	
	public String getOriginSerialNo() {
		return originSerialNo;
	}
	public void setOriginSerialNo(String originSerialNo) {
		this.originSerialNo = originSerialNo;
	}
	public String getSerialNo() {
		return serialNo;
	}
	public void setSerialNo(String serialNo) {
		this.serialNo = serialNo;
	}
	public String getBillType() {
		return billType;
	}
	public void setBillType(String billType) {
		this.billType = billType;
	}
		
	public String getStorageNo() {
		return storageNo;
	}
	public void setStorageNo(String storageNo) {
		this.storageNo = storageNo;
	}
	public String getStorageName() {
		return storageName;
	}
	public void setStorageName(String storageName) {
		this.storageName = storageName;
	}
	public String getItemNo() {
		return itemNo;
	}
	public void setItemNo(String itemNo) {
		this.itemNo = itemNo;
	}
	public String getItemDescribe() {
		return itemDescribe;
	}
	public void setItemDescribe(String itemDescribe) {
		this.itemDescribe = itemDescribe;
	}
	public String getUnitCode() {
		return unitCode;
	}
	public void setUnitCode(String unitCode) {
		this.unitCode = unitCode;
	}
	public String getUnitName() {
		return unitName;
	}
	public void setUnitName(String unitName) {
		this.unitName = unitName;
	}
	public BigDecimal getOrderAmount() {
		return orderAmount;
	}
	public void setOrderAmount(BigDecimal orderAmount) {
		this.orderAmount = orderAmount;
	}
	public BigDecimal getOrderAmountOld() {
		return orderAmountOld;
	}
	public void setOrderAmountOld(BigDecimal orderAmountOld) {
		this.orderAmountOld = orderAmountOld;
	}
	public BigDecimal getOrderAmountTax() {
		return orderAmountTax;
	}
	public void setOrderAmountTax(BigDecimal orderAmountTax) {
		this.orderAmountTax = orderAmountTax;
	}
	public BigDecimal getItemAmount() {
		return itemAmount;
	}
	public void setItemAmount(BigDecimal itemAmount) {
		this.itemAmount = itemAmount;
	}
	public BigDecimal getStoreItemAmount() {
		return storeItemAmount;
	}
	public void setStoreItemAmount(BigDecimal storeItemAmount) {
		this.storeItemAmount = storeItemAmount;
	}
	public BigDecimal getStoreItemIng() {
		return storeItemIng;
	}
	public void setStoreItemIng(BigDecimal storeItemIng) {
		this.storeItemIng = storeItemIng;
	}

	public String getEnterpriseNo() {
		return enterpriseNo;
	}
	public void setEnterpriseNo(String enterpriseNo) {
		this.enterpriseNo = enterpriseNo;
	}
	public String getEnterpriseName() {
		return enterpriseName;
	}
	public void setEnterpriseName(String enterpriseName) {
		this.enterpriseName = enterpriseName;
	}
	public String getfMasterID() {
		return fMasterID;
	}
	public void setfMasterID(String fMasterID) {
		this.fMasterID = fMasterID;
	}
	public BigDecimal getOrderAmountTotal() {
		return orderAmountTotal;
	}
	public void setOrderAmountTotal(BigDecimal orderAmountTotal) {
		this.orderAmountTotal = orderAmountTotal;
	}

	public String getItemProperty() {
		return itemProperty;
	}

	public void setItemProperty(String itemProperty) {
		this.itemProperty = itemProperty;
	}
	public String getSystemCode() {
		return systemCode;
	}
	public void setSystemCode(String systemCode) {
		this.systemCode = systemCode;
	}
	public String getEmployeeNo() {
		return employeeNo;
	}
	public void setEmployeeNo(String employeeNo) {
		this.employeeNo = employeeNo;
	}
	public String getEmployeeName() {
		return employeeName;
	}
	public void setEmployeeName(String employeeName) {
		this.employeeName = employeeName;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getStorageTypeD() {
		return storageTypeD;
	}
	public void setStorageTypeD(String storageTypeD) {
		this.storageTypeD = storageTypeD;
	}
	public String getStorageTypeDLabel() {
		return storageTypeDLabel;
	}
	public void setStorageTypeDLabel(String storageTypeDLabel) {
		this.storageTypeDLabel = storageTypeDLabel;
	}
	public String getProviderID() {
		return providerID;
	}
	public void setProviderID(String providerID) {
		this.providerID = providerID;
	}
	public String getStorageID() {
		return storageID;
	}
	public void setStorageID(String storageID) {
		this.storageID = storageID;
	}
	public String getItemID() {
		return itemID;
	}
	public void setItemID(String itemID) {
		this.itemID = itemID;
	}
	public String getFactoryID() {
		return factoryID;
	}
	public void setFactoryID(String factoryID) {
		this.factoryID = factoryID;
	}
	public String getResultStatus() {
		return resultStatus;
	}
	public void setResultStatus(String resultStatus) {
		this.resultStatus = resultStatus;
	}
	public String getItemName() {
		return itemName;
	}
	public void setItemName(String itemName) {
		this.itemName = itemName;
	}
	public int getQualityType() {
		return qualityType;
	}
	public void setQualityType(int qualityType) {
		this.qualityType = qualityType;
	}
	public String getQualityTypeLabel() {
		return qualityTypeLabel;
	}
	public void setQualityTypeLabel(String qualityTypeLabel) {
		this.qualityTypeLabel = qualityTypeLabel;
	}
	public String getBatchNo() {
		return batchNo;
	}
	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}
	public int getQualityPeriod() {
		return qualityPeriod;
	}
	public void setQualityPeriod(int qualityPeriod) {
		this.qualityPeriod = qualityPeriod;
	}
	public int getValidDays() {
		return validDays;
	}
	public void setValidDays(int validDays) {
		this.validDays = validDays;
	}
	public int getCheckoutAgainDays() {
		return checkoutAgainDays;
	}
	public void setCheckoutAgainDays(int checkoutAgainDays) {
		this.checkoutAgainDays = checkoutAgainDays;
	}
	public String getStoreNo() {
		return storeNo;
	}
	public void setStoreNo(String storeNo) {
		this.storeNo = storeNo;
	}
	public String getImages() {
		return images;
	}
	public void setImages(String images) {
		this.images = images;
	}
	public String getImageurl() {
		return imageurl;
	}
	public void setImageurl(String imageurl) {
		this.imageurl = imageurl;
	}
	public String getProcess() {
		return process;
	}
	public void setProcess(String process) {
		this.process = process;
	}
	public String getProcessLabel() {
		return processLabel;
	}
	public void setProcessLabel(String processLabel) {
		this.processLabel = processLabel;
	}
	public int getCheckin() {
		return checkin;
	}
	public void setCheckin(int checkin) {
		this.checkin = checkin;
	}
	public BigDecimal getPiecePackage() {
		return piecePackage;
	}
	public void setPiecePackage(BigDecimal piecePackage) {
		this.piecePackage = piecePackage;
	}
	public String getAllowed() {
		return allowed;
	}
	public void setAllowed(String allowed) {
		this.allowed = allowed;
	}


}